package com.caitaojun.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.caitaojun.domain.Items;
import com.caitaojun.service.ItemsService;
import com.caitaojun.mapper.ItemsMapper;

@Service
@Transactional
public class ItemsServiceImpl implements ItemsService {

	@Autowired
	private ItemsMapper itemsDao;

	@Override
	public Items save(Items items) {
		itemsDao.insertSelective(items);
		return items;
	}

	@Override
	public List<Items> save(List<Items> itemss) {
		for (Items items : itemss) {
			itemsDao.insertSelective(items);
		}
		return itemss;
	}

	@Override
	public void delete(Items items) {
		itemsDao.deleteByPrimaryKey(items.getId());
	}
	
	@Override
	public void batchDelete(String[] ids){
		for(String id : ids){
			itemsDao.deleteByPrimaryKey(Integer.valueOf(id));
		}
	}

	@Override
	public Items findOne(Items items) {
		return itemsDao.selectByPrimaryKey(items.getId());
	}
	
	@Override
	public List<Items> findPageData(Items pojo,Integer pageNumber,Integer pageSize) {
		return itemsDao.selectPageBySelective(pojo, (pageNumber-1)*pageSize, pageSize);
	}

	@Override
	public Integer selectCount(Items items) {
		return itemsDao.selectCount(items);
	}

}
